package com.itheima.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtils {
    /**
     * 将 Date 转为指定格式字符串
     */
    public static String date2String(Date date, String pattern) {
        if (date == null) return null;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}
